from .base import Base

from sqlalchemy import Column, ForeignKey, Index, Integer, String, DateTime, Date, Time, Float, Enum, Boolean
from sqlalchemy.sql import func
from sqlalchemy.orm import relation, backref

BOGUS_VALUE = -111

class VoteType(Base):
    __tablename__ = 'vote_type'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    display = Column(Boolean)
    description = Column(String)
    osm = Column(String)
    value_1 = Column(String)
    value_2 = Column(String)
    value_3 = Column(String)
    value_4 = Column(String)
    value_5 = Column(String)

class User(Base):
    __tablename__ = 'user'
    id = Column(Integer, primary_key=True)  
    name = Column(String, default="Anonymous Coward")
    password = Column(String, default="111")
    created = Column(DateTime, default=func.current_timestamp())

class Vote(Base):
    __tablename__ = 'vote'
    id = Column(Integer, primary_key=True)
    feature = Column(Integer)
    user = Column(
        Integer,
        ForeignKey(User.id),
        nullable=False,
        default=BOGUS_VALUE
    )
    type = Column(
        Integer,
        ForeignKey(VoteType.id),
        nullable=False
    )
    value   = Column(Integer)
    comment = Column(String)
    created = Column(DateTime, default=func.current_timestamp())
